package com.ynu.springbootappdemo.model.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ynu.springbootappdemo.common.entity.BaseEntity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;

@Entity
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
public class SkuItem extends BaseEntity {
    // 商品库存
    private int itemStock;
    // 商品图片
    private String itemImg;
    // 商品规格
    private String itemSpec;

    public SkuItem(int itemStock, String itemImg, String itemSpec) {
        this.itemStock = itemStock;
        this.itemImg = itemImg;
        this.itemSpec = itemSpec;
    }

    @ManyToOne(cascade = CascadeType.MERGE,fetch = FetchType.EAGER)
    @JoinColumn(name = "goods_id")
    @JsonIgnoreProperties("skuItems")
    private Goods goods;
}
